import 'package:flutter/material.dart';

//Flutter 圆角矩形裁剪
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: ClipRRect(
          //四个角 BorderRadius.circular(40)
          borderRadius: BorderRadius.only(topLeft: Radius.elliptical(40, 60)),
          //Clip.antiAlias,  平滑  默认
          //Clip.hardEdge  硬边裁剪  性能最好
          //Clip.antiAliasWithSaveLayer  高质量 抗锯齿  性能开销很大
          clipBehavior: Clip.antiAliasWithSaveLayer,
          child: Container(width: 300, height: 200, color: Colors.grey),
        ),
      ),
    );
  }
}
